import LineImgEff from "./LineImgEff";
/**author:yebinx email:yebinx@21cm.com*/
export default class LineImgEff2 extends Laya.Sprite{
    public static FLAG:string="LineImgEff2";
    private body0:LineImgEff;
	private body1:LineImgEff;
	private mSkin:string;
	/*0水平，1垂直**/
	private mBodyDir:number;
	private mWidth:number;
    constructor(_skin:string,_width:number=50,_dir:number=0){
        super();
        this.mSkin=_skin;
		this.mBodyDir=_dir;
		this.mWidth=_width;
        this.body0=new LineImgEff(_skin,_dir);
        this.body1=new LineImgEff(_skin,_dir);
        this.body0.updateRot(0);
        this.body1.updateRot(1);
        this.body0.setPos(0,0);
		this.body1.setPos(this.mWidth,0);
        this.addChild(this.body0);
        this.addChild(this.body1);
    }

    public play(_x:number,_y:number,_len1:number,_len2:number,_dir:number=0,_func:Function=null){
        this.pos(_x,_y);
        let tindex:number=0;
        this.rotation=_dir==0?0:90;
        this.body0.lenTw(_len1,()=>{
			tindex++;
			if(tindex==2){
				if(_func)_func();
				this.remvoe();
			}
		});
		this.body1.lenTw(_len2,()=>{
			tindex++;
			if(tindex==2){
				if(_func)_func();
				this.remvoe();
			}
		});
    }

    public remvoe(){
		this.removeSelf();
		Laya.Pool.recover(LineImgEff2.FLAG, this);
	}
}